Back to course home
0% completed
Vote For New Content
Meta Hard Problems
Sliding Window Median (hard)
Solution: Sliding Window Median
Alien Dictionary (hard)
Solution: Alien Dictionary
Minimum Window Substring (hard)
Solution: Minimum Window Substring
Best Meeting Point (hard)
Solution: Best Meeting Point
Maximum Sum of 3 Non-Overlapping Subarrays (hard)
Solution: Maximum Sum of 3 Non-Overlapping Subarrays
Making A Large Island (hard)
Solution: Making A Large Island
Basic Calculator (Hard)
Solution: Basic Calculator
Serialize and Deserialize Binary Tree (hard)
Solution: Serialize and Deserialize Binary Tree
Longest Increasing Path in a Matrix (hard)
Solution: Longest Increasing Path in a Matrix
Valid Palindrome III (hard)
Solution: Valid Palindrome III
Missing Element in Sorted Array (medium)
Problem Statement
Given an array arr containing unique integers in the ascending order, and integer k, return the kth missing number starting from the arr[0].
The missing numbers are those that are not present in the array, and greater than arr[0].
Examples
-
Example 1:
- Input:
arr = [3, 5, 6, 7], k = 2 - Expected Output:
8 - Justification: The missing numbers in sequence are 4 and 8. The 2nd missing number is 8.
- Input:
-
Example 2:
- Input:
arr = [1, 2, 4, 8], k = 3 - Expected Output:
6 - Justification: The missing numbers are 3, 5, 6, etc. The 3rd missing number is 6.
- Input:
-
Example 3:
- Input:
arr = [2, 3, 4, 7, 8, 10, 11], k = 2 - Expected Output:
6 - Justification: The missing numbers in this sequence start from 5, 6, 9... The 2nd missing number in this sequence is 6.
- Input:
Try it yourself
Try solving this question here:
Java
Saved to Cloud
. . . .
Solution: Clone Graph
Solution: Missing Element in Sorted Array
Mark as Completed
On this page
Problem Statement
Examples
Try it yourself